package cifa;

import java.io.BufferedReader;
import java.io.FileInputStream;
import java.io.InputStreamReader;

/**
 * @创建人 MBY381
 * @创建时间 2022/6/25 14:17
 * @描述 暂无
 */
public class CFTest {
    public static void main(String[] args) {
        String path = "./mby.txt";
        try{
            //打开文件，创建流
            BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(path)));

            //创建词法分析器
            CIFFAAnalysis la = new CIFFAAnalysis(reader);

            //输出二元组
            System.out.println("二元组表: ");
            Pair tuple = null;
            do{
                tuple = la.analysis();
                if(tuple!=null)
                    System.out.println(tuple);
            }while(tuple!=null);

            //输出标识符表
            System.out.println("\n标识符表:");
            for(int i = 0; i<la.getMarkTable().size(); i++){
                CharMark temp = la.getMarkTable().get(i);
                System.out.println("< "+temp.getKey()+" , "+temp.getValue()+" >");
            }

            //输出常数表
            System.out.println("\n常数表:");
            for(int i = 0; i<la.getConstTable().size(); i++){
                CharMark temp = la.getConstTable().get(i);
                System.out.println("< "+temp.getKey()+" , "+temp.getValue()+" >");
            }

            //关闭流
            reader.close();
        }catch(Exception e){
            System.out.println(e);
        }
    }

}

